import type { ResultData } from '@/types/commonType'
import type { DictItem, DriverItem, OrderItem, OrderRoute, OrderSearchParams } from '@/types/orderType'
import request from '@/utils/request'

export default {
  getOrderList(params: OrderSearchParams) {
    return request.get<ResultData<OrderItem>>('/order/list', params)
  },
  // 创建订单
  createOrder(params: OrderItem) {
    return request.post('/order/create', params)
  },
  //获取城市列表
  getCityList() {
    return request.get<DictItem[]>('/order/cityList')
  },
  // 获取车型列表
  getVehicleList() {
    return request.get<DictItem[]>('/order/vehicleList')
  },
  // 查询订单详情
  getOrderDetail(orderId: string) {
    return request.get<OrderItem>(`/order/detail/${orderId}`)
  },
  // 删除订单
  deleteOrder(params: { _id: string }) {
    return request.post('/order/delete', params)
  },
  // 更新订单轨迹
  updateOrderInfo(params: OrderRoute) {
    return request.post('/order/edit', params)
  },
  // 文件留导出
  orderExport(data: OrderSearchParams) {
    request.downLoad('/order/orderExport', data)
  },
  // 查询订单聚合
  getOrderCluster(cityId: number) {
    return request.get<Array<{ lng: string; lat: string }>>(`/order/cluster/${cityId}`)
  },
  // 查询司机列表
  getDriverList(params: { driverName: string; accountStatus: number }) {
    return request.get<ResultData<DriverItem>>(`/order/driver/list`, params)
  }
}
